//
//  EFSArticlesModel.m
//  luGongPro
//
//  Created by 王庆学 on 2017/8/28.
//  Copyright © 2017年 王庆学. All rights reserved.
//

#import "EFSArticlesModel.h"
#import "YSUtil.h"
#import "DateTools.h"


@implementation EFSArticlesModel

+ (NSDictionary *)JSONKeyPathsByPropertyKey{
    return @{
             @"mId":@"id",
             @"mPublishTimeMs":@"publishTimeMs"
             };
}

- (NSString *)publishTimeMs{
    if (_publishTimeMs.description && [_publishTimeMs.description rangeOfString:@"-"].location != NSNotFound) return _publishTimeMs.description;
    
    if (_publishTimeMs){
        NSDate *date = [NSDate dateWithTimeIntervalSince1970:[_publishTimeMs floatValue]/ 1000.00];
        _publishTimeMs = [date formattedDateWithFormat:@"yyyy-MM--dd HH:mm"];
    }
    return _publishTimeMs;
}

- (CGFloat)cellHeight{
    if (_cellHeight <= 0){
        _cellHeight = 183 - 72 + self.contentHeight + self.titleHeight;
    }
    return _cellHeight;
}

- (CGFloat)contentHeight{
    if (_contentHeight <= 0){
        _contentHeight = [YSUtil sizeForWidth:kWidth - 32 andTextSize:16 content:_introduction defaultHeight:23].height;
    }
    return _contentHeight;
}

- (CGFloat)titleHeight{
    if (_titleHeight <= 0){
        _titleHeight = [YSUtil sizeForWidth:kWidth - 58 andTextSize:16 content:_title defaultHeight:20].height;
    }
    return _titleHeight;
}

#pragma mark YGRenderProtocol
- (NSString *)floorIdentifier
{
    return @"YGBigClubCell";
}

@end
